var member_id = '',
	ws;
document.addEventListener('plusready',function(){
	member_id = plus.storage.getItem('id');
	ws = plus.webview.currentWebview();
	$.ajax({ 
		type:"post", 
		url:apiRoot+"?act=member_campus&op=mycampus",
		data:{member_id:member_id},
		dataType:'json',
		success:function(data){ 
			console.log(JSON.stringify(data)); 
			if(data.code == 200){
				if(data.datas.my){
					var html1 = html2 =html3 = html4 = '';
					var zt1 = zt2 = zt3 = zt4 = 0;  //判断该值是否为空
					$.each(data.datas.my, function(k,v) {
						switch(v.order_status){ 
							case '0':
								zt1 = zt1+1;
							    html1 += '<ul class="mui-table-view mycampus"  data-id="'+ v.xid +'">'+
											'<li class="mui-table-view-cell">'+
												'<a>'+ 
													'<img class="mui-media-object mui-pull-left" src="'+ (v.publisher.member_avatar?(user_pic + v.publisher.member_avatar):"../public/img/pic_img.jpg") +'">'+
													'<div class="mui-media-body">'+
														'<b>'+ v.publisher.member_truename +'</b>'+
														'<h5>'+
															'<span>主题：'+ v.title +'</span>'+
															'<span><map class="mui-h5 red">￥</map>'+ v.remuneration +'</span>'+								
														'</h5>'+
														'<p>'+
															'<span>服务时间：'+ v.targettime +'</span>'+										
														'</p>'+
													'</div>'+
												'</a>'+
											'</li>'+
										'</ul>';
							break;
							case '1' :
								zt2 = zt2+1;
							    html2 += '<ul class="mui-table-view mycampus"  data-id="'+ v.xid +'">'+
											'<li class="mui-table-view-cell">'+
												'<a>'+
													'<img class="mui-media-object mui-pull-left" src="'+ (v.recipient.member_avatar?(user_pic + v.recipient.member_avatar):"../public/img/pic_img.jpg") +'">'+
													'<div class="mui-media-body">'+
														'<b>接单人：'+ v.recipient.member_truename +'</b>'+
														'<h5>'+
															'<span>主题：'+ v.title +'</span>'+
															'<span><map class="mui-h5 red">￥</map>'+ v.remuneration +'</span>'+								
														'</h5>'+
														'<p>'+
															'<span>服务时间：'+ v.targettime +'</span>'+										
														'</p>'+
													'</div>'+
												'</a>'+
											'</li>'+
										'</ul>';
							break;
							case '2' :
								zt3 = zt3+1;
							    html3 += '<ul class="mui-table-view mycampus"  data-id="'+ v.xid +'">'+
											'<li class="mui-table-view-cell">'+
												'<a>'+
													'<img class="mui-media-object mui-pull-left" src="'+ (v.recipient.member_avatar?(user_pic + v.recipient.member_avatar):"../public/img/pic_img.jpg") +'">'+
													'<div class="mui-media-body">'+
														'<b>接单人：'+ v.recipient.member_truename +'</b>'+
														'<h5>'+
															'<span>主题：'+ v.title +'</span>'+
															'<span><map class="mui-h5 red">￥</map>'+ v.remuneration +'</span>'+								
														'</h5>'+
														'<p>'+
															'<span>服务时间：'+ v.targettime +'</span>'+										
														'</p>'+
													'</div>'+
												'</a>'+
											'</li>'+
										'</ul>';
							break;
							case '3' :
								zt4 = zt4+1;
							    html4 += '<ul class="mui-table-view mycampus"  data-id="'+ v.xid +'">'+
											'<li class="mui-table-view-cell">'+
												'<a>'+
													'<img class="mui-media-object mui-pull-left" src="'+ (v.recipient.member_avatar?(user_pic + v.recipient.member_avatar):"../public/img/pic_img.jpg") +'">'+
													'<div class="mui-media-body">'+
														'<b>接单人：未接单</b>'+
														'<h5>'+
															'<span>主题：'+ v.title +'</span>'+
															'<span><map class="mui-h5 red">￥</map>'+ v.remuneration +'</span>'+								
														'</h5>'+
														'<p>'+
															'<span>服务时间：'+ v.targettime +'</span>'+										
															'<span class="mui-pull-right">删除</span>'+
														'</p>'+
													'</div>'+
												'</a>'+
											'</li>'+
										'</ul>';
							break;
							case '4' :
								zt4 = zt4+1;
							    html4 += '<ul class="mui-table-view mycampus" data-id="'+ v.xid +'">'+
											'<li class="mui-table-view-cell">'+
												'<a>'+
													'<img class="mui-media-object mui-pull-left" src="'+ (v.recipient.member_avatar?(user_pic + v.recipient.member_avatar):"../public/img/pic_img.jpg") +'">'+
													'<div class="mui-media-body">'+
														'<b>接单人：'+ v.recipient.member_truename +'</b>'+
														'<h5>'+
															'<span>主题：'+ v.title +'</span>'+
															'<span><map class="mui-h5 red">￥</map>'+ v.remuneration +'</span>'+								
														'</h5>'+
														'<p>'+
															'<span>服务时间：'+ v.targettime +'</span>'+										
															'<span class="mui-pull-right">删除</span>'+
														'</p>'+
													'</div>'+
												'</a>'+
											'</li>'+
										'</ul>';
							break;
						}
					})
					var zt = '<div style="width: 80%;margin: 40px auto;text-align: center;font-size: 22px;">你还没有数据！！！！</div>';
					if(zt1 > 0){
						$('#item1mobile .mui-scroll').html(html1);
					}else{
						$('#item1mobile .mui-scroll').html(zt);
					}
					if(zt2 > 0){
						$('#item2mobile .mui-scroll').html(html2);
					}else{
						$('#item2mobile .mui-scroll').html(zt);
					}
					if(zt3 > 0){
						$('#item3mobile .mui-scroll').html(html3);
					}else{
						$('#item3mobile .mui-scroll').html(zt);
					}
					if(zt4 > 0){
						$('#item4mobile .mui-scroll').html(html4);
					}else{
						$('#item4mobile .mui-scroll').html(zt);
					}
				}else{
					var html = '<div style="width: 80%;margin: 40px auto;text-align: center;font-size: 18px;">你还没有数据！！！！</div>';
					$('#item1mobile .mui-scroll').html(html);
					$('#item2mobile .mui-scroll').html(html);
					$('#item3mobile .mui-scroll').html(html);
					$('#item4mobile .mui-scroll').html(html);
				}
				if(data.datas.jd){ 
					var html5 = html6 =html7 = '';
					var zhi1 = zhi2 = zhi3 = 0;           //判断该值是否为空
					$.each(data.datas.jd, function(k,v) {
						switch(v.order_status){ 
							case '1' :
								zhi1 = zhi1 + 1;
							    html5 += '<ul class="mui-table-view othcampus" data-id="'+ v.xid +'">'+
											'<li class="mui-table-view-cell">'+
												'<a>'+
													'<img class="mui-media-object mui-pull-left" src="'+ (v.publisher.member_avatar?(user_pic + v.publisher.member_avatar):"../public/img/pic_img.jpg") +'">'+
													'<div class="mui-media-body">'+
														'<b>发布者：'+ v.publisher.member_truename +'</b>'+
														'<h5>'+
															'<span>主题：'+ v.title +'</span>'+
															'<span><map class="mui-h5 red">￥</map>'+ v.remuneration +'</span>'+								
														'</h5>'+
														'<p>'+
															'<span>服务时间：'+ v.targettime +'</span>'+										
														'</p>'+
													'</div>'+
												'</a>'+
											'</li>'+
										'</ul>';
							break;
							case '2' :
								zhi2 = zhi2 + 1;
							    html6 += '<ul class="mui-table-view othcampus" data-id="'+ v.xid +'">'+
											'<li class="mui-table-view-cell">'+
												'<a>'+
													'<img class="mui-media-object mui-pull-left" src="'+ (v.publisher.member_avatar?(user_pic + v.publisher.member_avatar):"../public/img/pic_img.jpg") +'">'+
													'<div class="mui-media-body">'+
														'<b>发布者：'+ v.publisher.member_truename +'</b>'+
														'<h5>'+
															'<span>主题：'+ v.title +'</span>'+
															'<span><map class="mui-h5 red">￥</map>'+ v.remuneration +'</span>'+								
														'</h5>'+
														'<p>'+
															'<span>服务时间：'+ v.targettime +'</span>'+										
														'</p>'+
													'</div>'+
												'</a>'+
											'</li>'+
										'</ul>';
							break;
							case '3' :
								zhi3 = zhi3 + 1;
							    html7 += '<ul class="mui-table-view othcampus" data-id="'+ v.xid +'">'+
											'<li class="mui-table-view-cell">'+
												'<a>'+
													'<img class="mui-media-object mui-pull-left" src="'+ (v.publisher.member_avatar?(user_pic + v.publisher.member_avatar):"../public/img/pic_img.jpg") +'">'+
													'<div class="mui-media-body">'+
														'<b>发布者：'+ v.publisher.member_truename +'</b>'+
														'<h5>'+
															'<span>主题：'+ v.title +'</span>'+
															'<span><map class="mui-h5 red">￥</map>'+ v.remuneration +'</span>'+								
														'</h5>'+
														'<p>'+
															'<span>服务时间：'+ v.targettime +'</span>'+										
															'<span class="mui-pull-right">删除</span>'+
														'</p>'+
													'</div>'+
												'</a>'+
											'</li>'+
										'</ul>';
							break;
							case '4' :
								zhi3 = zhi3 + 1;
							    html7 += '<ul class="mui-table-view othcampus" data-id="'+ v.xid +'">'+
											'<li class="mui-table-view-cell">'+
												'<a>'+
													'<img class="mui-media-object mui-pull-left" src="'+ (v.publisher.member_avatar?(user_pic + v.publisher.member_avatar):"../public/img/pic_img.jpg") +'">'+
													'<div class="mui-media-body">'+
														'<b>发布者：'+ v.publisher.member_truename +'</b>'+
														'<h5>'+
															'<span>主题：'+ v.title +'</span>'+
															'<span><map class="mui-h5 red">￥</map>'+ v.remuneration +'</span>'+								
														'</h5>'+
														'<p>'+
															'<span>服务时间：'+ v.targettime +'</span>'+										
															'<span class="mui-pull-right">删除</span>'+
														'</p>'+
													'</div>'+
												'</a>'+
											'</li>'+
										'</ul>';
							break;
						}
					})
					var zt = '<div style="width: 80%;margin: 40px auto;text-align: center;font-size: 18px;">你还没有数据！！！！</div>';
					if(zhi1 > 0){
						$('#item5mobile .mui-scroll').html(html5);
					}else{
						$('#item5mobile .mui-scroll').html(zt);
					}
					if(zhi2 > 0){
						$('#item6mobile .mui-scroll').html(html6);
					}else{
						$('#item6mobile .mui-scroll').html(zt);
					}
					if(zhi3 > 0){
						$('#item7mobile .mui-scroll').html(html7);
					}else{
						$('#item7mobile .mui-scroll').html(zt);
					}
					
					
					
				}else{
					var html = '<div style="width: 80%;margin: 40px auto;text-align: center;font-size: 18px;">你还没有数据！！！！</div>';
					$('#item5mobile .mui-scroll').html(html);
					$('#item6mobile .mui-scroll').html(html);
					$('#item7mobile .mui-scroll').html(html);
				} 
			}
//			my--详情 
			$('.mycampus').unbind('tap');
			$('.mycampus').on('tap',function(){
				var _this = $(this);
				var xid = _this.attr('data-id');
				var nwaiting = plus.nativeUI.showWaiting();//显示原生等待框
				var webviewContent= plus.webview.create('./myCampus_details.html','myCampus_details.html',{},{xid:xid,spage:ws.id});//后台创建webview并打开show.html
				webviewContent.addEventListener("loaded", function() { //注册新webview的载入完成事件
			        nwaiting.close(); //新webview的载入完毕后关闭等待框
			        webviewContent.show("slide-in-right",500); //把新webview窗体显示出来，显示动画效果为速度200毫秒的右侧移入动画
			    }, false);
			})
//			othis--详情 
			$('.othcampus').unbind('tap');
			$('.othcampus').on('tap',function(){
				var _this = $(this);
				var xid = _this.attr('data-id');
				var nwaiting = plus.nativeUI.showWaiting();//显示原生等待框
				var webviewContent= plus.webview.create('./othCampus_details.html','othCampus_details.html',{},{xid:xid,spage:ws.id});//后台创建webview并打开show.html
				webviewContent.addEventListener("loaded", function() { //注册新webview的载入完成事件
			        nwaiting.close(); //新webview的载入完毕后关闭等待框
			        webviewContent.show("slide-in-right",500); //把新webview窗体显示出来，显示动画效果为速度200毫秒的右侧移入动画
			    }, false);
			})
		}, 
		error:function(e){
			toast('连接失败！');
		}
	});
},false);
